#!/bin/bash
#
# this is supposed to be run from a cron job as root
#
# This script will run yadt-yum upgrade -y and log the output to a logfile
#

# set logfile, we create a new logfile for every minute. Since cron jobs
# are usually run at most once per minute this should be safe to give us
# a new logfile for each cron-triggered run.

# initialize proper environment
. /etc/profile

# source yadt configuration
. /etc/default/yadt
LOG_DIR="$YADT_LOG_DIR/$(date +%Y-%m-%d)/yadt-auto-upgrade"
umask 002
mkdir -p "$LOG_DIR"
exec  yadt-yum -y upgrade &>$LOG_DIR/$(date +"%M").log </dev/null
